using System;
using System.Windows.Forms;
using BizTalk.BuildGenerator.UI.Navigation;

namespace BizTalk.BuildGenerator.UI.UserControls
{
    public partial class ApplicationDeploymentControl : UserControl, IWizardControl
    {
        private ApplicationDeployment _Deployment = new ApplicationDeployment();

        public ApplicationDeploymentControl()
        {
            InitializeComponent();
        }

        public void RegisterDeployment(ApplicationDeployment deployment)
        {
            _Deployment = deployment;
        }

        private void ApplicationDeploymentControl_Load(object sender, EventArgs e)
        {
            DeploymentPathTextBox.Text = _Deployment.PublishMsiPath;
        }

        private void BrowseFileButton_Click(object sender, EventArgs e)
        {
            DialogResult dr = saveFileDialog.ShowDialog();
            if (dr == DialogResult.OK)
            {
                DeploymentPathTextBox.Text = saveFileDialog.FileName;
            }
        }

        #region IWizardControl Members

        public MoveNextResult MoveNext()
        {
            MoveNextResult result = new MoveNextResult();
            _Deployment.PublishMsiPath = DeploymentPathTextBox.Text;

            if (string.IsNullOrEmpty(_Deployment.PublishMsiPath))
            {
                result.CanMoveNext = false;
                result.AddError("The msi path has not been selected");
            }
            else
                result.CanMoveNext = true;

            return result;
        }

        #endregion
    }
}